package com.ruoyi.project.system.function.domain;

import com.ruoyi.project.system.dict.utils.DictUtils;
import com.ruoyi.project.system.function.bean.CategoryMap;
import lombok.Data;

/**
 * @program: NH
 * @description: 生产经营性收入
 * @author: 郑吉志
 * @create: 2023-02-16 17:44
 **/
@Data
public class DetailDB {
    Integer id;
    Integer incomeDataId;
    Integer firstCategory;
    Integer secondaryCategory;
    Integer tertiaryCategory;
    Double quantity;
    Double amount;

    public DetailDB() {
    }

    public DetailDB(Integer id, Integer incomeDataId, Integer firstCategory, Integer secondaryCategory, Integer tertiaryCategory, Double quantity, Double amount) {
        this.id = id;
        this.incomeDataId = incomeDataId;
        this.firstCategory = firstCategory;
        this.secondaryCategory = secondaryCategory;
        this.tertiaryCategory = tertiaryCategory;
        this.quantity = quantity;
        this.amount = amount;
    }

    public DetailDB(Detail detail){
        this.id=detail.getId();
        this.incomeDataId=detail.getIncomeDataId();
        int firstCategory= Integer.parseInt(DictUtils.getDictValue("first_category_type",detail.getFirstCategory()));
        String type= CategoryMap.map.get(detail.getFirstCategory());
        int secondaryCategory=Integer.parseInt(DictUtils.getDictValue(type,detail.getSecondaryCategory()));
        String thirdType=CategoryMap.map.get(detail.getSecondaryCategory());
        int tertiaryCategory=Integer.parseInt(DictUtils.getDictValue(thirdType,detail.getTertiaryCategory()));
        this.firstCategory=firstCategory;
        this.secondaryCategory=secondaryCategory;
        this.tertiaryCategory=tertiaryCategory;
        this.quantity=detail.getQuantity().equals("")?0:Double.parseDouble(detail.getQuantity());
        this.amount= detail.getAmount().equals("")?0.0:Double.parseDouble(detail.getAmount());
    }
}